package com.jida.tijian.controller;

import com.jida.tijian.domain.Users;

import com.jida.tijian.dto.ResponseObject;
import com.jida.tijian.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


//处理套餐模块的需求
@RestController
public class SetmealController {
    //1.建立业务service模块
    @Autowired
    SetmealService setmealService;

    //2.接受前端请求
    @RequestMapping("/setmeal")
    //一定要记得写RequestBody!!接收前端传过来的数据
    public ResponseObject listSetmeal(@RequestBody Users users) {
        //输出前端传来的数据
        System.out.println("前端传递到控制层的数据是一个Users对象\n:" + "通过users.getSex()方法获得sex：" + users.getSex());
//        System.out.println(users.getSex() + 1);
        //调用业务层的方法 并且返回给前端
        ResponseObject responseObject = setmealService.listSetmeal(users.getSex());
        return responseObject;
    }

}
